package net.lab1024.sa.admin.module.business.picture.controller;

import net.lab1024.sa.admin.module.business.picture.domain.form.PictureAddForm;
import net.lab1024.sa.admin.module.business.picture.domain.form.PictureQueryForm;
import net.lab1024.sa.admin.module.business.picture.domain.form.PictureUpdateForm;
import net.lab1024.sa.admin.module.business.picture.domain.vo.PictureVO;
import net.lab1024.sa.admin.module.business.picture.service.PictureService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.List;

/**
 * 全景图添加 Controller
 *
 * @Author 骆伟林
 * @Date 2025-10-22 17:09:49
 * @Copyright 软件需求工程第八组
 */

@RestController
@Tag(name = "全景图添加")
public class PictureController {

    @Resource
    private PictureService pictureService;

    @Operation(summary = "分页查询 @author 骆伟林")
    @PostMapping("/picture/queryPage")
    @SaCheckPermission("picture:query")
    public ResponseDTO<PageResult<PictureVO>> queryPage(@RequestBody @Valid PictureQueryForm queryForm) {
        return ResponseDTO.ok(pictureService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 骆伟林")
    @PostMapping("/picture/add")
    @SaCheckPermission("picture:add")
    public ResponseDTO<String> add(@RequestBody @Valid PictureAddForm addForm) {
        return pictureService.add(addForm);
    }

    @Operation(summary = "批量新增 @author 骆伟林")
    @PostMapping("/picture/batchAdd")
    @SaCheckPermission("picture:add")
    public ResponseDTO<String> batchAdd(@RequestBody @Valid ValidateList<PictureAddForm> addFormList) {
        return pictureService.batchAdd(addFormList);
    }


    @Operation(summary = "更新 @author 骆伟林")
    @PostMapping("/picture/update")
    @SaCheckPermission("picture:update")
    public ResponseDTO<String> update(@RequestBody @Valid PictureUpdateForm updateForm) {
        return pictureService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 骆伟林")
    @PostMapping("/picture/batchDelete")
    @SaCheckPermission("picture:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return pictureService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 骆伟林")
    @GetMapping("/picture/delete/{pitureId}")
    @SaCheckPermission("picture:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long pitureId) {
        return pictureService.delete(pitureId);
    }

    @Operation(summary = "根据地点id获取图片列表 @author 骆伟林")
    @GetMapping("/picture/getPictureByAddressId/{addressId}")
    public ResponseDTO<List<PictureVO>> getPictureByAddressId(@PathVariable Long addressId) {
        return ResponseDTO.ok(pictureService.getPictureListByAddressId(addressId));
    }

    @Operation(summary = "根据图片id获取详情 @author 骆伟林")
    @GetMapping("/picture/getPictureById/{pitureId}")
    public ResponseDTO<PictureVO> getPictureById(@PathVariable Long pitureId) {
        return ResponseDTO.ok(pictureService.getPictureById(pitureId));
    }

}
